<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="公司名称">
              <a-input placeholder="请输入公司名称" v-model="queryParam.companyName" />
            </a-form-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="用户">
              <a-input placeholder="请输入用户" v-model="queryParam.user" />
            </a-form-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="支出日期">
              <a-date-picker v-model="queryParam.payDate" placeholder="请选择支出日期" style="width: 100%;" />
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">

          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="link" @click="handleAdd" icon="plus">新增</a-button>
     <!--  <a-button type="link" icon="download" @click="handleExportXls('财务订单')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
        @change="handleImportExcel">
        <a-button type="link" icon="import">导入</a-button>
      </a-upload> -->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">删除</a-menu-item>
        </a-menu>
        <a-button type="link" style="margin-left: 8px">批量操作<a-icon type="down" /></a-button>
      </a-dropdown>
      <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
        selectedRowKeys.length
      }}</a>项
      <a v-if="selectedRowKeys.length > 0" style="margin-left: 12px" @click="onClearSelected">清空</a>

      <table-columns-setter v-model="columns" style="float: right;" />
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table ref="table" size="middle" bordered rowKey="id" :scroll="{ x: true }" :columns="columns"
        :dataSource="dataSource" :pagination="ipagination" :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" class="j-table-force-nowrap"
        :components="drag(columns)" @change="handleTableChange">

          <span slot="action" slot-scope="text, record">
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a >删除</a>
          </a-popconfirm>
         
        </span>

      </a-table>
    </div>

    <financial-modal ref="modalForm" @ok="modalFormOk" @refreshs="loadListData"/>
  </a-card>
</template>

<script>

import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import financialModal from './modules/financialModal'
import TableColumnsSetter from '../common/components/TableColumnsSetter'
import { ListMixin } from '../common/mixins/ListMixin'
import XEUtils from "xe-utils";
// import {OrderListMixin} from '../common/mixins/OrderListMixin'
export default {
  name: "FinancialManagement",
  mixins: [JeecgListMixin, ListMixin],
  components: { TableColumnsSetter, financialModal },

  data() {
    return {
      description: '产品',
      billReportId: '731513187758551040',
      queryParam: {
          companyName: '',
          user: '',
          payDate: null,
        },

      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          fixed: 'left',
          width: 40,
          align: "center",
          customRender: (t, r, index) => parseInt(index) + 1
        },
        {
          title: '公司名称',
          fixed: 'left',
          width: 160,
          align: "center",
          dataIndex: 'companyName',
        },
        {
          title: '支出类型',
          width: 160,
          align: "center",
          dataIndex: 'payType_dictText',
        },
        {
          title: '金额',
          align: "center",
          width: 160,
          dataIndex: 'amount',
          customRender: (text) => `¥${text}`,
        },
       
        {
          title: '用户',
          width: 160,
          align: "center",
          dataIndex: 'user'
        },
        {
          title: '支出日期',
          align: "center",
          dataIndex: 'payDate',
          width: 260,
          customRender: t => !t ? "" : (t.length > 10 ? t.substr(0, 10) : t),
        },
        {
          title: '创建时间',
          width: 260,
          align: "center",
          dataIndex: 'createTime',
          customRender: t => !t ? "" : (t.length > 10 ? t.substr(0, 10) : t),
        },
        {
          title: '操作',
          dataIndex: 'action',
          fixed: 'right',
          width: 120,
          align: "center",
          scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action'
          },
        }
      ],
      url: {
          list: "/wr/financeOtherPay/list",
          delete: "/wr/financeOtherPay/delete",
          deleteBatch: "/wr/financeOtherPay/deleteBatch",
          exportXlsUrl: "/wr/financeOtherPay/exportXls",
          importExcelUrl: "/wr/financeOtherPay/importExcel",
        },
      dictOptions: {},
    }
  },

  methods: {
    loadListData(){
            this.searchQuery()
            console.log('loadListData调用成功');
            
        },
    initDictConfig() { },
    handleAdd() {
      this.$refs.modalForm.title = '新增';
      this.$refs.modalForm.visible = true;
      this.$refs.modalForm.disableSubmit = false;
      this.$refs.modalForm.action = 'add';
      this.$nextTick(() => {
        this.$refs.modalForm.resetForm();
      });
    },
    handleEdit(record) {
      this.$refs.modalForm.title = '编辑';
      this.$refs.modalForm.visible = true;
      this.$refs.modalForm.disableSubmit = false;
      this.$refs.modalForm.action = 'edit';
      this.$nextTick(() => {
        this.$refs.modalForm.setFormValues(record);
      });
    },
    modalFormOk() {
      this.loadDataList();
    }
  }

}
</script>

<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '../common/less/List.less';
</style>
